package com.rbac.common.exception;

import com.rbac.common.enums.BusinessErrorCode;
import lombok.Getter;

@Getter
public class BusinessException extends RuntimeException {
    
    private final BusinessErrorCode errorCode;
    
    public BusinessException(BusinessErrorCode errorCode) {
        super(errorCode.getMessage());
        this.errorCode = errorCode;
    }
    
    public BusinessException(BusinessErrorCode errorCode, String message) {
        super(message);
        this.errorCode = errorCode;
    }
    
    public BusinessException(BusinessErrorCode errorCode, Throwable cause) {
        super(errorCode.getMessage(), cause);
        this.errorCode = errorCode;
    }
    
    public BusinessException(BusinessErrorCode errorCode, String message, Throwable cause) {
        super(message, cause);
        this.errorCode = errorCode;
    }
    
    public Integer getCode() {
        return errorCode.getCode();
    }
}